package com.xinhua.erp.controller;

import com.xinhua.erp.pojo.Authority;
import com.xinhua.erp.pojo.Result;
import com.xinhua.erp.pojo.User;
import com.xinhua.erp.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName UserController
 * @Description TODO
 * @Date 2020/1/1 下午2:58
 * @Version 1.0
 **/
@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("{id}")
    public Result findById(@PathVariable long id) {
        return userService.findById(id);
    }

    @DeleteMapping("{id}")
    public Result deleteById(@PathVariable long id) {
        return userService.deleteById(id);
    }

    @PostMapping
    public Result save(@RequestBody User user) {
        return userService.save(user);
    }

    @PutMapping
    public Result update(@RequestBody User user) {
        return userService.update(user);
    }
}
